
package net.atremmedia.gwt.actionjava.examples.frame;

import actionjava.display.Graphics;
import actionjava.display.Shape;
import actionjava.display.TextField;

public class AJExampleTitle
{
	private double x;
	private double y;
	private String title;
	private TextField titleField;
	private Shape buttonBG;
	private AJExampleOverview overview;

	public AJExampleTitle(double x, double y, String title, AJExampleOverview overview)
	{
		this.x = x;
		this.y = y;
		this.title = title;
		this.overview = overview;
		this.initialize();
	}

	private void initialize()
	{
		createBG();
		overview.addChild(buttonBG);

		createTitlefield();
		overview.addChild(titleField);
	}

	private void createBG()
	{
		buttonBG = new Shape();
		buttonBG.setX(x);
		buttonBG.setY(y);
		buttonBG.setAlpha(.5);

		Graphics graphs = buttonBG.getGraphics();
		graphs.beginFill("#FFFFFF");
		graphs.drawRect(0, 0, 675, 25);
		graphs.endFill();
	}

	private void createTitlefield()
	{
		titleField = new TextField(title);
		titleField.setX(x + 5);
		titleField.setY(y + 5);
		titleField.setSize(15);
	}

	public void destroy()
	{
		overview.removeChild(buttonBG);
		overview.removeChild(titleField);
	}
}
